import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [{
    path: '/',
    redirect: '/index',
  },
  {
    path: '/home',
    name: 'home',
    component: () => import( /* webpackChunkName: "LSD.bighome" */ '../views/home.vue'),
    children: [{
      path: '/index',
      name: 'index',
      component: () => import( /* webpackChunkName: "LSD.bighome" */ '../views/indexs/index.vue'),
      meta: {
        title: '大屏', //这个title属性名是自定义的, 随便起
      },
    }]
  },
  {
    path: '/datalist',
    name: 'DataList',
    component: () => import('../views/indexs/component/listDataCenter/listDataCenter.vue'),
    meta: {
      title: '数据中心列表', //这个title属性名是自定义的, 随便起
    },
  },
  {
    path: '/dataIplist',
    name: 'dataIplist',
    component: () => import('../views/indexs/component/listDataIpCenter/listDataIpCenter.vue'),
    meta: {
      title: '数据中心IP段列表', //这个title属性名是自定义的, 随便起
    },
  },
  {
    path: '/poplist',
    name: 'poplist',
    component: () => import('../views/indexs/component/listPop/listPop.vue'),
    meta: {
      title: 'Pop列表', //这个title属性名是自定义的, 随便起
    },
  },
  {
    path: '/assetlist',
    name: 'assetlist',
    component: () => import('../views/indexs/component/listAssetProbeData/listAssetProbeData.vue'),
    meta: {
      title: '资产探测数据列表', //这个title属性名是自定义的, 随便起
    },
  },
  {
    path: '/emphasisGoal',
    name: 'emphasisGoal',
    component: () => import('../views/indexs/component/listEmphasisGoal/listEmphasisGoal.vue'),
    meta: {
      title: '重点目标', //这个title属性名是自定义的, 随便起
    },
  },

];
const router = new VueRouter({
  mode: "history",
  // base: process.env.BASE_URL,
  routes
});

router.beforeEach((to, from, next) => {
  let title = to.meta.title
  // document.title: 标签栏的标题
  document.title = title

  //相当于一个拦截器
  next() //调用后, 才能继续跳转操作
})

export default router;